//
// Example code for implementing IDL interfaces in file ./CORBA_defs/collaboration.idl
//

#include <iostream>
#include <collaboration.h>

//
// Example class implementing IDL interface collaboration::MIDataAccessor
//
class collaboration_MIDataAccessor_i: public POA_collaboration::MIDataAccessor {
private:
  // Make sure all instances are built on the heap by making the
  // destructor non-public
  //virtual ~collaboration_MIDataAccessor_i();
public:
  // standard constructor
  collaboration_MIDataAccessor_i();
  virtual ~collaboration_MIDataAccessor_i();

  // methods corresponding to defined IDL attributes and operations
  collaboration::ListOfApplications* applications();
  ::CORBA::Boolean add_application(const char* app);
  ::CORBA::Boolean remove_application(const char* app);
  collaboration::MIConnection* login(const char* app, const char* user, const char* pass);
  char* connect_user(const char* app, const char* user);
  void disconnect_user(const char* app, const char* user);
  void update_user_time(const char* app, const char* user);
  collaboration::MIConnection* change_connected_user_role(const char* app, const char* user, const char* role);
  collaboration::ListOfUsersAndRoles* connected_users(const char* app);
  collaboration::ListOfUsers* connected_users_info(const char* app);
  collaboration::ListOfUsers* users_info(const char* app);
  collaboration::ListOfRoles* roles_info(const char* app);
  collaboration::MIUser* user_info(const char* app, const char* user_name);
  collaboration::MIRole* role_info(const char* app, const char* role_name);
  collaboration::ListOfUserNames* role_users(const char* app, const char* role);
  collaboration::ListOfUserNames* non_updated_users(const char* app);
  collaboration::ListOfRoleNames* application_roles(const char* app);
  collaboration::ListOfUserNames* application_users(const char* app);
  collaboration::ListOfComponentNames* application_components(const char* app);
  collaboration::ListOfRoles* allowed_roles(const char* app, const char* user);
  collaboration::ListOfRoleNames* allowed_role_names(const char* app, const char* user);
  ::CORBA::Long get_user_component_permissions(const char* app, const char* user, const char* comp);
  ::CORBA::Boolean set_user_component_permissions(const char* app, const char* user, const char* comp, ::CORBA::Long level);
  ::CORBA::Long get_role_component_permissions(const char* app, const char* role, const char* comp);
  ::CORBA::Boolean set_role_component_permissions(const char* app, const char* role, const char* comp, ::CORBA::Long level);
  char* user_actual_role(const char* app, const char* user);
  ::CORBA::Boolean new_user_allowed_role(const char* app, const char* user, const char* role);
  ::CORBA::Boolean new_user(const char* app, const char* user, const char* password, const char* default_role, ::CORBA::Boolean is_admin);
  ::CORBA::Boolean new_role(const char* app, const char* role);
  ::CORBA::Boolean remove_allowed_user_role(const char* app, const char* user, const char* role);
  ::CORBA::Boolean remove_user(const char* app, const char* user);
  ::CORBA::Boolean remove_role(const char* app, const char* role);
  collaboration::ListOfApplicationNames* get_applications_names();
  collaboration::MIApplication* get_application(const char* name);
  void commit();

};

//
// Example implementational code for IDL interface collaboration::MIDataAccessor
//
collaboration_MIDataAccessor_i::collaboration_MIDataAccessor_i(){
  // add extra constructor code here
}
collaboration_MIDataAccessor_i::~collaboration_MIDataAccessor_i(){
  // add extra destructor code here
}
//   Methods corresponding to IDL attributes and operations
collaboration::ListOfApplications* collaboration_MIDataAccessor_i::applications(){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfApplications* collaboration_MIDataAccessor_i::applications()>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::add_application(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::add_application(const char* app)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::remove_application(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::remove_application(const char* app)>"
}

collaboration::MIConnection* collaboration_MIDataAccessor_i::login(const char* app, const char* user, const char* pass){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::MIConnection* collaboration_MIDataAccessor_i::login(const char* app, const char* user, const char* pass)>"
}

char* collaboration_MIDataAccessor_i::connect_user(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <char* collaboration_MIDataAccessor_i::connect_user(const char* app, const char* user)>"
}

void collaboration_MIDataAccessor_i::disconnect_user(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <void collaboration_MIDataAccessor_i::disconnect_user(const char* app, const char* user)>"
}

void collaboration_MIDataAccessor_i::update_user_time(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <void collaboration_MIDataAccessor_i::update_user_time(const char* app, const char* user)>"
}

collaboration::MIConnection* collaboration_MIDataAccessor_i::change_connected_user_role(const char* app, const char* user, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::MIConnection* collaboration_MIDataAccessor_i::change_connected_user_role(const char* app, const char* user, const char* role)>"
}

collaboration::ListOfUsersAndRoles* collaboration_MIDataAccessor_i::connected_users(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUsersAndRoles* collaboration_MIDataAccessor_i::connected_users(const char* app)>"
}

collaboration::ListOfUsers* collaboration_MIDataAccessor_i::connected_users_info(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUsers* collaboration_MIDataAccessor_i::connected_users_info(const char* app)>"
}

collaboration::ListOfUsers* collaboration_MIDataAccessor_i::users_info(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUsers* collaboration_MIDataAccessor_i::users_info(const char* app)>"
}

collaboration::ListOfRoles* collaboration_MIDataAccessor_i::roles_info(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfRoles* collaboration_MIDataAccessor_i::roles_info(const char* app)>"
}

collaboration::MIUser* collaboration_MIDataAccessor_i::user_info(const char* app, const char* user_name){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::MIUser* collaboration_MIDataAccessor_i::user_info(const char* app, const char* user_name)>"
}

collaboration::MIRole* collaboration_MIDataAccessor_i::role_info(const char* app, const char* role_name){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::MIRole* collaboration_MIDataAccessor_i::role_info(const char* app, const char* role_name)>"
}

collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::role_users(const char* app, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::role_users(const char* app, const char* role)>"
}

collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::non_updated_users(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::non_updated_users(const char* app)>"
}

collaboration::ListOfRoleNames* collaboration_MIDataAccessor_i::application_roles(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfRoleNames* collaboration_MIDataAccessor_i::application_roles(const char* app)>"
}

collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::application_users(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfUserNames* collaboration_MIDataAccessor_i::application_users(const char* app)>"
}

collaboration::ListOfComponentNames* collaboration_MIDataAccessor_i::application_components(const char* app){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfComponentNames* collaboration_MIDataAccessor_i::application_components(const char* app)>"
}

collaboration::ListOfRoles* collaboration_MIDataAccessor_i::allowed_roles(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfRoles* collaboration_MIDataAccessor_i::allowed_roles(const char* app, const char* user)>"
}

collaboration::ListOfRoleNames* collaboration_MIDataAccessor_i::allowed_role_names(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfRoleNames* collaboration_MIDataAccessor_i::allowed_role_names(const char* app, const char* user)>"
}

::CORBA::Long collaboration_MIDataAccessor_i::get_user_component_permissions(const char* app, const char* user, const char* comp){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Long collaboration_MIDataAccessor_i::get_user_component_permissions(const char* app, const char* user, const char* comp)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::set_user_component_permissions(const char* app, const char* user, const char* comp, ::CORBA::Long level){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::set_user_component_permissions(const char* app, const char* user, const char* comp, ::CORBA::Long level)>"
}

::CORBA::Long collaboration_MIDataAccessor_i::get_role_component_permissions(const char* app, const char* role, const char* comp){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Long collaboration_MIDataAccessor_i::get_role_component_permissions(const char* app, const char* role, const char* comp)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::set_role_component_permissions(const char* app, const char* role, const char* comp, ::CORBA::Long level){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::set_role_component_permissions(const char* app, const char* role, const char* comp, ::CORBA::Long level)>"
}

char* collaboration_MIDataAccessor_i::user_actual_role(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <char* collaboration_MIDataAccessor_i::user_actual_role(const char* app, const char* user)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::new_user_allowed_role(const char* app, const char* user, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::new_user_allowed_role(const char* app, const char* user, const char* role)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::new_user(const char* app, const char* user, const char* password, const char* default_role, ::CORBA::Boolean is_admin){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::new_user(const char* app, const char* user, const char* password, const char* default_role, ::CORBA::Boolean is_admin)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::new_role(const char* app, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::new_role(const char* app, const char* role)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::remove_allowed_user_role(const char* app, const char* user, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::remove_allowed_user_role(const char* app, const char* user, const char* role)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::remove_user(const char* app, const char* user){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::remove_user(const char* app, const char* user)>"
}

::CORBA::Boolean collaboration_MIDataAccessor_i::remove_role(const char* app, const char* role){
  // insert code here and remove the warning
  #warning "Code missing in function <::CORBA::Boolean collaboration_MIDataAccessor_i::remove_role(const char* app, const char* role)>"
}

collaboration::ListOfApplicationNames* collaboration_MIDataAccessor_i::get_applications_names(){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::ListOfApplicationNames* collaboration_MIDataAccessor_i::get_applications_names()>"
}

collaboration::MIApplication* collaboration_MIDataAccessor_i::get_application(const char* name){
  // insert code here and remove the warning
  #warning "Code missing in function <collaboration::MIApplication* collaboration_MIDataAccessor_i::get_application(const char* name)>"
}

void collaboration_MIDataAccessor_i::commit(){
  // insert code here and remove the warning
  #warning "Code missing in function <void collaboration_MIDataAccessor_i::commit()>"
}



// End of example implementational code



int main(int argc, char** argv)
{
  try {
    // Initialise the ORB.
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    // Obtain a reference to the root POA.
    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);

    // We allocate the objects on the heap.  Since these are reference
    // counted objects, they will be deleted by the POA when they are no
    // longer needed.
    collaboration_MIDataAccessor_i* mycollaboration_MIDataAccessor_i = new collaboration_MIDataAccessor_i();


    // Activate the objects.  This tells the POA that the objects are
    // ready to accept requests.
    PortableServer::ObjectId_var mycollaboration_MIDataAccessor_iid = poa->activate_object(mycollaboration_MIDataAccessor_i);


    // Obtain a reference to each object and output the stringified
    // IOR to stdout
    {
      // IDL interface: collaboration::MIDataAccessor
      CORBA::Object_var ref = mycollaboration_MIDataAccessor_i->_this();
      CORBA::String_var sior(orb->object_to_string(ref));
      std::cout << "IDL object collaboration::MIDataAccessor IOR = '" << (char*)sior << "'" << std::endl;
    }



    // Obtain a POAManager, and tell the POA to start accepting
    // requests on its objects.
    PortableServer::POAManager_var pman = poa->the_POAManager();
    pman->activate();

    orb->run();
    orb->destroy();
  }
  catch(CORBA::TRANSIENT&) {
    cerr << "Caught system exception TRANSIENT -- unable to contact the "
         << "server." << endl;
  }
  catch(CORBA::SystemException& ex) {
    cerr << "Caught a CORBA::" << ex._name() << endl;
  }
  catch(CORBA::Exception& ex) {
    cerr << "Caught CORBA::Exception: " << ex._name() << endl;
  }
  catch(omniORB::fatalException& fe) {
    cerr << "Caught omniORB::fatalException:" << endl;
    cerr << "  file: " << fe.file() << endl;
    cerr << "  line: " << fe.line() << endl;
    cerr << "  mesg: " << fe.errmsg() << endl;
  }
  return 0;
}

